package br.ucb.tcc.aiml;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamImplicit;

public abstract class ComponenteBase implements IComponent, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -9123112662824784866L;
	
	@XStreamImplicit
	private List<IComponent> component = new ArrayList<IComponent>();
	
	private String value;
	
	public ComponenteBase() {
	}
	
	public ComponenteBase(String value) {
		setValue(value);
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Override
	public void add(IComponent componente) {
		this.component.add(componente);
	}	
	
	public List<IComponent> getComponentes() {
		return component;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((component == null) ? 0 : component.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ComponenteBase other = (ComponenteBase) obj;
		if (component == null) {
			if (other.component != null)
				return false;
		} else if (!component.equals(other.component))
			return false;
		return true;
	}
	
	

}
